<div class="modal-dialog">
    <div class="modal-content">
        <div class="modal-header">
            <button data-dismiss="modal" class="close" type="button">×</button>
            <h4 class="modal-title">用户合并</h4>
        </div>
        <div class="modal-body">
            <div role="alert" class="alert alert-warning">
                系统通过手机号或统一用户unionid来判断用户唯一性，来合并重复的用户信息
            </div>
            <div class="panel panel-stat">
                <div class="panel-body">
                    <div class="col-md-3">
                        <div class="title">手机号重复(人)</div>
                        <div class="num-wrapper">
                            <a class="num" href="javascript:;">{php echo count($mobiles)}</a>
                        </div>
                    </div>
                    <div class="col-md-3">
                        <div class="title">手机号为空(人)</div>
                        <div class="num-wrapper">
                            <a class="num" href="javascript:;">{$nomobile}</a>
                        </div>
                    </div>
                    <div class="col-md-3">
                        <div class="title">unionid重复(人)</div>
                        <div class="num-wrapper">
                            <a class="num" href="javascript:;">{php echo count($unionids)}</a>
                        </div>
                    </div>
                    <div class="col-md-3">
                        <div class="title">unionid为空(人)</div>
                        <div class="num-wrapper">
                            <a class="num" href="javascript:;">{$nounionid}</a>
                        </div>
                    </div>
                </div>
            </div>
            <div class="text-center">
                <div class="member-merge-progress" style="display: none;">
                    <div class="progress">
                        <div class="progress-bar" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100">0%</div>
                    </div>
                    <div class="modal-tip">
                        系统正在为您合并重复用户，请耐心等待~~~
                    </div>
                </div>
                {if !empty($mobiles) || !empty($unionids)}
                <button class="btn btn-primary btn-member-merge" onclick="member_merge();">开始合并用户</button>
                {/if}
            </div>
        </div>
    </div>
</div>
<script language='javascript'>
    function member_merge() {
        $('.btn-member-merge').hide();
        $('.member-merge-progress').show();

        var merge = function() {
            $.post("{php echo web_url('member/wlMember/membermerge');}", function (data) {
                if(data.errno == 0){
                    var pragress = data.data.success/data.data.total*100;
                    $('.progress-bar').css('width', pragress + '%');
                    $('.progress-bar').html(pragress.toFixed(2) + '%');
                    merge();
                } else if (data.errno == 1) {
                    $('.member-merge-progress').hide();
                    tip.alert('重复用户合并成功', function () {
                        location.href = "{php echo web_url('member/wlMember/memberIndex');}";
                    });
                }
            },'json');
        };
        merge();
    }
</script>